/*
Copyright (C) 2022-2024 Inspur Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/
package db

import "fmt"

const postgresName = "postgres"

func newEngine(name string) IEngine {
	switch name {
	case postgresName:
		return &PostgresEngine{}
	case mysqlName:
		return &MysqlEngine{}
	default:
		return &PostgresEngine{}
	}
}

var (
	_ IEngine = &PostgresEngine{}
)

type PostgresEngine struct {
}

func (p PostgresEngine) EngineInfo(dbCfg *DBConfig) string {
	pgInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
		dbCfg.Host, dbCfg.Port, dbCfg.User, dbCfg.Password, dbCfg.DBName)
	return pgInfo
}

func (p PostgresEngine) EngineName() string {
	return postgresName
}
